<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @search='search' @getHeight='getHeight' />
    <!-- table区域-begin -->
      <div class='page_table'>
        <vxe-grid
          ref='xGrid'
          :border='true'
          :resizable='true'
          :showOverflow='true'
          size='mini'
          :loading='loading'
          :height='pageHeight-seachHeight-90'
          :align='left'
          :columns='columns'
          :data='dataSource'
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          :toolbar-config='tableToolbar'
          :checkbox-config="checkboxConfig"
          v-bind='vexConfig'
          @checkbox-change='selectChangeEvent'
          @checkbox-all='selectChangeEvent'
        >
          <template #toolbar_buttons>
            <div class='table-operator'>
              <a-dropdown v-if="selectedRowKeys.length > 0">
                <a-menu slot="overlay">
                  <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
                </a-menu>
<!--                <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
              </a-dropdown>
              <a-button type="primary" @click="downExportXls('sfaVisitReport_service')">导出</a-button>
            </div>
          </template>

          <template #status='{ row }'>
            <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
          </template>
          <template #action='{ row:record }'>
            <a @click='handleEdit1(record)'>编辑</a>
            <span v-if='record.fileUrl'>
            <a-divider type='vertical' />
            <a :href='record.fileUrl'>下载</a>
          </span>
          </template>
          <template #pager>
            <vxe-pager
              :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
              :currentPage.sync='ipagination.current'
              :page-size.sync='ipagination.pageSize'
              :total='ipagination.total'
              :pageSizes='ipagination.pageSizeOptions'
              @page-change='handlePageChange'>
            </vxe-pager>
          </template>
        </vxe-grid>
      </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <sfaVisitSummaryEntity-modal ref="modalForm" @ok="modalFormOk"></sfaVisitSummaryEntity-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import SfaVisitSummaryEntityModal from './modules/SfaVisitSummaryModal'
  import { PageListMixin } from '@/mixins/PageListMixin'

  export default {
    name: "SfaVisitSummaryList",
    mixins:[PageListMixin],
    components: {
      SfaVisitSummaryEntityModal
    },
    data () {
      return {
        description: '拜访完成进度查询',
        //查询区域
        searchConfig:[
          {
            type: 'input',
            name: 'createBy',
            placeholder: '人员编码'
          },
          {
            type: 'input',
            name: 'createName',
            placeholder: '人员姓名'
          },
          {
            type: 'input',
            name: 'positionName',
            placeholder: '职位名称'
          },
          {
            type: 'date-range', //范围选择
            range: ['visitDateStart', 'visitDateEnd'],
            name: 'range',
            format: 'YYYY-MM-DD',
            placeholder: ['开始时间', '结束时间']
          }
        ],
        // 表头
        columns: [
          { type: 'checkbox', width: 50, fixed: 'left' },
          {
            title: '人员编码',
            minWidth:80,
            field: 'createBy'
          },
          {
            title: '人员姓名',
            minWidth:80,
            field: 'createName'
          },
          {
            title: '职位名称',
            minWidth:80,
            field: 'positionName'
          },
          {
            title: '所属组织',
            minWidth:80,
            field: 'orgName'
          },
          {
            title: '开始时间',
            minWidth:80,
            field: 'visitDateStart'
          },
          {
            title: '结束时间',
            minWidth:80,
            field: 'visitDateEnd'
          },
          // {
          //   title: '拜访类型',
          //   minWidth:80,
          //   field: 'visitType'
          // },
          // {
          //   title: '日期',
          //   minWidth:80,
          //   field: 'visitDate'
          // },
          {
            title: '计划完成经销商数',
            minWidth:120,
            field: 'planVisitSum'
          },
          {
            title: '实际完成经销商数',
            minWidth:120,
            field: 'realityVisitSum'
          },
          {
            title: '完成百分比',
            minWidth:100,
            field: 'scoreRatio'
          },
        ],
        isorter: {
          permflag: 'visit_plan_list'
        },
		url: {
          list: window._CONFIG['domianSfaURL'] + "/visit/sfa/visit/report/findPageList",
          exportXlsUrl: window._CONFIG['domianSfaURL'] + "/sfaVisitSummaryService/todoExcel",
          // delete: "/visit/sfaVisitSummaryEntity/delete",
          deleteBatch: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitSummaryController/deleteBatch",
          // importExcelUrl: "visit/sfaVisitSummaryEntity/importExcel",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>